home *** CD-ROM | disk | FTP | other *** search
/ Windows 6-Pak - Disc 4 / Windows 6-Pak (InfoMagic) (Disc 4) (1999).ISO / Text-Chat-Scripts / pp-320m.exe / pp300 / a-idents.mrc < prev    next >
Encoding:
Text File  |  1998-10-10  |  27.8 KB  |  601 lines

  1. ; -----------------------------------------------------
  2. ; Peace and Protection (by misspai)
  3. ; -----------------------------------------------------
  4. ; Internal identifiers (basic)
  5. ; -----------------------------------------------------
  6. _tf2o if ($1) return On | return Off
  7. _tf2yn if ($1) return Yes | return No
  8. _tf2any if ($1) return $_p2s($2) | return $_p2s($3-)
  9. _o2tf if (($left($1,2) == On) || ($left($1,1) == Y)) return $true | return $false
  10. _s2p if ($1 == $null) return | return $replace($1-,$chr(32),)
  11. _p2s if ($1 == $null) return | return $replace($1-,,$chr(32))
  12. _s2c if ($1 == $null) return | return $replace($1-,$chr(32),$chr(44))
  13. _c2s if ($1 == $null) return | return $replace($1-,$chr(44),$chr(32))
  14. _c2sd set %.c2sd $chr(160) $+ - | return $_f2s($replace($1-,$chr(44),%.c2sd))
  15. _s2cs if ($1 == $null) return | set %.s2cs $chr(44) $+ $chr(160) | return $_f2s($replace($1-,$chr(32),%.s2cs))
  16. _s2sd if ($1 == $null) return | set %.s2sd $chr(160) $+ - | return $_f2s($replace($1-,$chr(32),%.s2sd))
  17. _s2f if ($1 == $null) return | return $replace($1-,$chr(32),$chr(160))
  18. _f2s if ($1 == $null) return | return $replace($1-,$chr(160),$chr(32))
  19. _a2x if ($1 == $null) return | return $replace($1-,&,&&)
  20. _a1x if ($1 == $null) return | return $replace($1-,&&,&)
  21. _sfext return $replace($replace($1-,.mp3,.mp│),.mp2,.mp▓)
  22. _noquote if ($1 == $null) return | return $replace($1-,",'')
  23. _noparen if ($1 == $null) return | return $replace($replace($1-,$chr(40),[),$chr(41),])
  24. _iniprep if ($1 == $null) return | return $replace($replace($replace($replace($1-,[,$chr(40)),],$chr(41)),=,-),$chr(32),_)
  25. _writeprep if ($1 == $null) return | return $replace($replace($replace($replace($replace($1-,,$chr(141)),,$chr(142)),,$chr(143)),,$chr(144)),,$chr(157))
  26. _readprep if ($1 == $null) return | return $replace($replace($replace($replace($replace($1-,$chr(141),),$chr(142),),$chr(143),),$chr(144),),$chr(157),)
  27. _ffprep return $replace($replace($replace($1-,$chr(32),?),-,?),_,?)
  28. _ccdef {
  29.   unset %.zz.ret
  30.   set %.zz.num $_numtok(15,$1-)
  31.   set %.zz.cur 1
  32.   :loop
  33.   set %.zz.tok $gettok($_s2p($1-),%.zz.cur,15)
  34.   set %.zz.ret %.zz.ret $+ %.zz.tok
  35.   if ( isin %.zz.tok) { set %.zz.ret %.zz.ret $+  | set %.zz.tok %.zz.tok $+  }
  36.   if ($calc($count(%.zz.tok,) % 2) == 1) set %.zz.ret %.zz.ret $+ 
  37.   if ($calc($count(%.zz.tok,) % 2) == 1) set %.zz.ret %.zz.ret $+ 
  38.   if ($calc($count(%.zz.tok,) % 2) == 1) set %.zz.ret %.zz.ret $+ 
  39.   if ($_vi(.zz.cur) <= %.zz.num) goto loop
  40.   return $_p2s(%.zz.ret)
  41. }
  42. _i return $calc( [ $1 ] + 1)
  43. _j return $calc( [ $1 ] - 1)
  44. _vi inc % $+ [ $1 ] | return % [ $+ [ $1 ] ]
  45. _vd dec % $+ [ $1 ] | return % [ $+ [ $1 ] ]
  46. _round if ($len($gettok($1,2,46)) <= $2) return $1 | return $round($1,$2)
  47. _p if (($1 == 0) || ($2 == 0)) return 0% | return $_round($calc($1 * 100 / $2),2) $+ %
  48. _lchop return $left($2-,$calc($len($2-) - $1))
  49. _rchop return $right($2-,$calc($len($2-) - $1))
  50. _lpad %.lpad = $str($2,$1) $+ $3- | return $right(%.lpad,$calc($1 + $len($3-) - $len($strip($3-))))
  51. _rpad %.rpad = $3- $+ $str($2,$1) | return $left(%.rpad,$calc($1 + $len($3-) - $len($strip($3-))))
  52. _ltok if ($1 == 0) return | return $gettok($3-,1- [ $+ [ $1 ] ] ,$2)
  53. _rtok if ($1 == 0) return | if ($calc($gettok($3-,0,$2) - $_j($1)) < 1) return $3- | return $gettok($3-, [ [ $calc($gettok($3-,0,$2) - $_j($1)) ] $+ ] - ,$2)
  54. _numtok if ($2 == $null) return 0 | return $gettok($2-,0,$1)
  55. _if if ($4 != $null) return $_if2($1-) | if ($1 $2 $3) return $true | return $false
  56. _if2 if (& isin $4) { if (($1 $2 $3) && ($5 $6 $7)) return $true | return $false } | if (($1 $2 $3) || ($5 $6 $7)) return $true | return $false
  57. _ifn if ($1 == $null) return null | return $1
  58. _hpop if (($snick($active,0) == $_j($nick($active,0))) && ($nick($active,0) > 10)) return $false | return $true
  59. _exec $1- | return
  60. _nick if ((! !isin $1) || ($left($1,1) == !)) return * | return $gettok($1,1,33)
  61. _identd if ($left($1,1) == !) return $remove($gettok($1,1,64),!) | if (! !isin $1) { if ((@ !isin $1) || ($left($1,1) == @)) return * | return $remove($gettok($1,1,64),!) } | if ($right($1,1) == !) return * | set %.idd $_rchop($pos($1,!),$left($1,$_j($pos($1,@)))) | if (%.idd == $null) return * | else return %.idd
  62. _domain if ((@ !isin $1) || ($left($1,1) == @)) { if ((! isin $1) || ($1 == $null)) return * | return $remove($1,@) } | if ($right($1,1) == @) return * | return $gettok($1,2,64)
  63. _fixmask return $_nick($1) $+ ! $+ $_identd($1) $+ @ $+ $_domain($1)
  64. _not if ($1) return $false | return $true
  65. _setting if (% [ $+ [ $1. $+ [ $2 ] ] ] != $null) return % [ $+ [ $1. $+ [ $2 ] ] ] | return % [ $+ [ $1 ] ]
  66. _color return  $+ $colour($1)
  67. _plural if ($2 == 1) return $1 | return $1 $+ s
  68. _plural2 if ($3 == 1) return $1 | return $2
  69. _col2text {
  70.   set %.color $remove($remove($remove($remove($1,),),),)
  71.   if (%.color == $null) unset %.fore
  72.   else set %.fore $calc($gettok(%.color,1,44) % 16)
  73.   if (, isin %.color) set %.back $calc($gettok(%.color,2,44) % 16)
  74.   else set %.back $colour(back)
  75.   unset %.text
  76.   if ( isin $1) set %.text bold
  77.   if ( isin $1) set %.text %.text underline
  78.   if ( isin $1) set %.text %.text reverse
  79.   elseif (%.fore != $null) {
  80.     set %.text %.text $gettok(white-black-blue-green-light red-red-purple-orange-yellow-light green-cyan-light cyan-light blue-light purple-grey-light grey,$_i(%.fore),45)
  81.     if (%.back != $colour(back)) set %.text %.text on $gettok(white-black-blue-green-light red-red-purple-orange-yellow-light green-cyan-light cyan-light blue-light purple-grey-light grey,$_i(%.back),45)
  82.   }
  83.   if (%.text == $null) return none
  84.   return %.text
  85. }
  86. _dynpop if ($1) return %pp.popup | if (3.1 isin $os) return $chr(160) | return $str($chr(160),2)
  87. _genflood {
  88.   _timersinc %delay. [ $+ [ $1 ] ] $2 $3
  89.   if (%halt. [ $+ [ $1 ] ] < % [ $+ [ $2 ] ] ) set %.+halt $true
  90.   if (%max. [ $+ [ $1 ] ] <= % [ $+ [ $2 ] ] ) return $true
  91.   return $false
  92. }
  93. _genfloodchan {
  94.   _timersinc $_setting(delay. [ $+ [ $1 ] ] ,$4) $2 [ $+ [ $4 ] ] $3
  95.   if ($_setting(max. [ $+ [ $1 ] ] ,$4) <= % [ $+ [ $2 $+ [ $4 ] ] ] ) return $true
  96.   return $false
  97. }
  98. _isopen {
  99.   if (($1 == -a) || ($1 == -s) || ($1 == -ai2) || ($1 == -si2)) return $true
  100.   elseif ($chan($1) == $1) return $true
  101.   elseif ($query($1) == $1) return $true
  102.   elseif ($left($1,1) == =) { if ($chat($remove($1,=)) == $remove($1,=)) return $true | return $false }
  103.   elseif ($window($1) == $1) return $true
  104.   return $false
  105. }
  106. _ischan if ($left($1,1) isin +&#) return $true | return $false
  107. _ismask if (((@ isin $1) && (! isin $1)) || (* isin $1)) return $true | return $false
  108. _isxw {
  109.   unset %.xw %.xw.msg
  110.   if (%pp.net == undernet) {
  111.     if (X ison $1) { if (($ial(X!cservice@undernet.org,0) == 1) || ($address(X,5) == $null)) set %.xw X }
  112.     elseif (W ison $1) { if (($ial(W!cservice@undernet.org,0) == 1) || ($address(W,5) == $null)) set %.xw W }
  113.   }
  114.   if (($2 == V) && (%.xw == $null)) { _error These commands require %col.target $+ X or %col.target $+ W to be on the channel. | halt }
  115.   if (%.xw != $null) set %.xw.msg $_xwtarg(%.xw)
  116.   return %.xw
  117. }
  118. _xwtarg if ($1 == X) return X@channels.undernet.org | return W@channels2.undernet.org
  119. _getnicks {
  120.   if (xw isin $3) _isxw $1
  121.   unset %.gn.find
  122.   if ($2 == $null) set %.gn.num $ialchan(*,$1,0)
  123.   else set %.gn.num $ialchan($2,$1,0)
  124.   if (%.gn.num == 0) return $null
  125.   :loop
  126.   if ($2 == $null) set %.gn.find %.gn.find $_getnick2($1,$ialchan(*,$1,%.gn.num).nick,$3)
  127.   else set %.gn.find %.gn.find $_getnick2($1,$ialchan($2,$1,%.gn.num).nick,$3)
  128.   if ($_vd(.gn.num) > 0) goto loop
  129.   return %.gn.find
  130. }
  131. _getnick2 {
  132.   if (+o isin $3) if ($2 !isop $1) return
  133.   if (-o isin $3) if ($2 isop $1) return
  134.   if ($2 == $me) if (not isin $3) return
  135.   if (xw isin $3) if ($2 == %.xw) return
  136.   return $2
  137. }
  138. _getchans {
  139.   unset %.gn.find
  140.   if ($chan(0) == 0) return $null
  141.   set %.gn.num $chan(0)
  142.   :loop
  143.   set %.gn.find %.gn.find $chan(%.gn.num)
  144.   if ($_vd(.gn.num) > 0) goto loop
  145.   return %.gn.find
  146. }
  147. _numsend {
  148.   set %.ns.num $send(0)
  149.   set %.ns.count 0
  150.   :loop
  151.   if (($1 == $send(%.ns.num)) && ($send(%.ns.num).status != inactive)) inc %.ns.count
  152.   if ($_vd(.ns.num) > 0) goto loop
  153.   return %.ns.count
  154. }
  155. _aopt if (%+disp.address) return  $+ %col.addr $+ ( $+ $1 $+  $+ %col.addr $+ ) $_opt($2-) | return $_opt($2-)
  156. _opt set %-cf1 whois " $+ $1" | set %-keybop.nick $1 | set %-keybop.addr $2 | if ($3 == $null) unset %-keybop.chan | else set %-keybop.chan $3 | if ($group(#_fkeysound) == on) return | elseif (%+disp.options) return %col.option $+ (F8:Kick ShiftF8:Ban CtrlF1:Whois) | else return
  157. _keys {
  158.   set %.ky.chk $_s2c($1-)
  159.   set %.ky.num $_numtok(44,%.ky.chk)
  160.   unset %.ky.ret
  161.   :loop
  162.   set %.ky.ret $_ppcfg(Keys,$gettok(%.ky.chk,%.ky.num,44)) $+ , $+ %.ky.ret
  163.   if ($_vd(.ky.num > 0)) goto loop
  164.   return $_lchop(1,%.ky.ret)
  165. }
  166. _ppcfg if ($2 == $null) set %.read $readini -n $_ppdir $+ config.ini settings $_iniprep($1) | else set %.read $readini -n $_ppdir $+ config.ini $1 $_iniprep($2-) | return $_readprep(%.read)
  167. _ppblk set %.read $readini -n $_ppdir $+ black.ini Blacklist $_iniprep($1-) | return $_readprep(%.read)
  168. _ppdef set %.read $readini -n $_ppdir $+ default.ini $1 $_iniprep($2-) | return $_readprep(%.read)
  169. _ppdef2 set %.read $readini -n $_ppdir $+ fancy.ini $1 $_iniprep($2-) | return $_readprep(%.read)
  170. _ppseen if ($2 == $null) set %.read $readini -n $_ppdir $+ lastseen.ini settings $_iniprep($1) | else set %.read $readini -n $_ppdir $+ lastseen.ini $1 $_iniprep($2-) | return $_readprep(%.read)
  171. _ppdesc set %.read $readini -n $_ppdir $+ sound.ini description $_iniprep($1-) | return $_readprep(%.read)
  172. _ppqhelp set %.read $readini -n $_ppdir $+ qhelp.ini quickhelp $_iniprep($1-) | return $_readprep(%.read)
  173. _mircdir if ($chr(32) isin $mircdir) return | else return $mircdir
  174. _ppdir if ($chr(32) isin $mircdir) return pp300\ | else return $mircdirpp300\
  175. _ppsub return pp300
  176. _favorites if ($_ppcfg(misc,favoritesbynet)) return $_ppcfg(favorites,%pp.net) | return $_ppcfg(misc,favorites)
  177. _mpdir return $_ppcfg(sound,mpdir)
  178. _mididir return $mididir $+ ; $+ $_ppcfg(sound,moremididir)
  179. _wavedir return $wavedir $+ ; $+ $_ppcfg(sound,morewavedir)
  180. _mp2exe return $_ppcfg(sound,mp2player)
  181. _mp3exe return $_ppcfg(sound,mp3player)
  182. _thedir {
  183.   set %.td.ext $_mapext($remove($1,.))
  184.   if (%.td.ext isin mp2.mp3) return $_mpdir
  185.   elseif (%.td.ext == mid) return $_mididir
  186.   elseif (%.td.ext == wav) return $_wavedir
  187.   else {
  188.     set %.td.ext %.td.ext $+ Dir
  189.     set %.td.ext $_ppcfg(Sound,%.td.ext)
  190.     if (%.td.ext == $null) return $_ppcfg(Sound,OtherDir)
  191.     return %.td.ext
  192.   }
  193. }
  194. _getmsg {
  195.   set %.gm.ret $_ppcfg($1,$2)
  196.   if ($left(%.gm.ret,8) == !Random:) set %.gm.ret $read -n $_adddir($gettok($gettok(%.gm.ret,1,33),2-,58))
  197.   if (%.gm.ret == $null) set %.gm.ret $_ppdef($1,$2)
  198.   if (&col isin %.gm.ret) {
  199.     unset %.gm.col1 %.gm.col2
  200.     set %.gm.col1  $+ $gettok(01 02 03 04 05 06 07 10 12 13 14,$r(1,11),32)
  201.     :redo | set %.gm.col2  $+ $gettok(01 02 03 04 05 06 07 10 12 13 14,$r(1,11),32) | if (%.gm.col1 == %.gm.col2) goto redo
  202.     set %.gm.ret $replace($replace(%.gm.ret,&col1&,%.gm.col1),&col2&,%.gm.col2)
  203.   }
  204.   :repeat
  205.   if (&count isin %.gm.ret) {
  206.     %.gm.pos = $pos(%.gm.ret,&count) + 5
  207.     set %.gm.tag $gettok($_rchop(%.gm.pos,%.gm.ret),1,38)
  208.     if (%.gm.tag == $null) goto done
  209.     set %.gm.type counter- $+ $left(%.gm.tag,1)
  210.     set %.gm.num $_rchop(1,%.gm.tag)
  211.     if (%.gm.num == $null) set %.gm.num 0
  212.     set %.gm.old $_ppcfg(%.gm.type,%.gm.num)
  213.     inc %.gm.old
  214.     _writecfg %.gm.type %.gm.num %.gm.old
  215.     set %.gm.tag &count $+ %.gm.tag $+ &
  216.     set %.gm.ret $replace(%.gm.ret,%.gm.tag,%.gm.old)
  217.     goto repeat
  218.   }
  219.   :done
  220.   return $replace($replace($replace($replace(%.gm.ret,&me&,$me),&[&,%[),&]&,%]),&ver&,%pp.ver)
  221. }
  222. ; Formats a msg with <$etc$ >$etc$ (cannot overlap but can nest) Whatever is between is replaced with $etc(in between)
  223. ; <$etc,blah$ >$etc,heh$ will use blah, as initial parameters and ,heh as final parameters
  224. ; Also, !$etc$ is replaced with $etc
  225. ;  is NOT $chr(127) in these aliases! BE CAREFUL
  226. _finalmsg {
  227.   if ($1 == $null) return
  228.   if ($ !isin $1-) return $_stripout($1-)
  229.   set %.fm.ret $replace($replace($1-,$chr(32),ì),!$,Ç)
  230.   if ($left(%.fm.ret,1) == Ç) set %.fm.ret ì $+ %.fm.ret
  231.   set %.fm.num $_numtok(128,%.fm.ret)
  232.   if (%.fm.num > 1) {
  233.     set %.fm.ret2 $gettok(%.fm.ret,1,128)
  234.     set %.fm.cur 2
  235.     :loop
  236.     set %.fm.id $chr(36) $+ $gettok($gettok(%.fm.ret,%.fm.cur,128),1,36)
  237.     set %.fm.ret2 %.fm.ret2 $+ [ [ $_p2s(%.fm.id) ] ] $+ $_rchop($len(%.fm.id),$gettok(%.fm.ret,%.fm.cur,128))
  238.     if ($_vi(.fm.cur) <= %.fm.num) goto loop
  239.     set %.fm.ret %.fm.ret2
  240.   }
  241.   if (<$ isin %.fm.ret) {
  242.     set %.fm.ret $replace($replace(%.fm.ret,<$,Ç),>$,ü)
  243.     set %.fm.ret $_dofm1(1,%.fm.ret)
  244.   }
  245.   return $_stripout($replace(%.fm.ret,ì,$chr(32)))
  246. }
  247. _dofmv return %. [ $+ [ $1 $+ [ $2 ] ] ]
  248. _dofms set %. [ $+ [ $1 $+ [ $2 ] ] ] $3-
  249. _dofm2 if ($2 == $null) return | return $_dofm1($_i($1),$2-)
  250. _dofm1 {
  251.   if (Ç !isin $2-) return $2-
  252.   _dofms $1 fm.todo $2- | _dofms $1 fm.done
  253.   :do
  254.   if ($left($_dofmv($1,fm.todo),1) == Ç) _dofms $1 fm.todo $_rchop(1,$_dofmv($1,fm.todo))
  255.   else { _dofms $1 fm.done $_dofmv($1,fm.done) $+ $gettok($_dofmv($1,fm.todo),1,128) | _dofms $1 fm.todo $gettok($_dofmv($1,fm.todo),2-,128) }
  256.   _dofms $1 fm.id $gettok($_dofmv($1,fm.todo),1,36) | _dofms $1 fm.todo $gettok($_dofmv($1,fm.todo),2-,36)
  257.   _dofms $1 fm.ask $gettok($replace($_dofmv($1,fm.todo), ü [ $+ [ $_dofmv($1,fm.id) ] ] ,Ä),1,142)
  258.   _dofms $1 fm.param $replace($_dofm2($1,$_dofmv($1,fm.ask)),ì,$chr(32))
  259.   _dofms $1 fm.todo $_rchop($_i($len($_dofmv($1,fm.ask))),$_dofmv($1,fm.todo))
  260.   _dofms $1 fm.todo $gettok($_dofmv($1,fm.todo),2-,36)
  261.   _dofms $1 fm.id $chr(36) $+ $_dofmv($1,fm.id) $+ $chr(40) $+ $_dofmv($1,fm.param) $+ $chr(41)
  262.   return $_dofmv($1,fm.done) $+ [ [ $_dofmv($1,fm.id) ] ] $+ $_dofm2($1,$_dofmv($1,fm.todo))
  263. }
  264. _fixmode {
  265.   unset %.fm.final
  266.   set %.fm.bit +
  267.   set %.fm.pos 1
  268.   :loop
  269.   if ($mid($1,%.fm.pos,1) isin -+) set %.fm.bit $mid($1,%.fm.pos,1)
  270.   else set %.fm.final %.fm.final $+ %.fm.bit $+ $mid($1,%.fm.pos,1)
  271.   if ($_vi(.fm.pos) <= $len($1)) goto loop
  272.   return %.fm.final
  273. }
  274. _patch {
  275.   set %.pa.num $_numtok(44,$1)
  276.   set %.pa.ret $1
  277.   :loop
  278.   set %.pa.ch $gettok(%.pa.ret,%.pa.num,44)
  279.   if ($_not($_ischan(%.pa.ch))) {
  280.     set %.pa.new $chr(35) $+ %.pa.ch
  281.     set %.pa.ret $puttok(%.pa.ret,%.pa.new,%.pa.num,44)
  282.   }
  283.   if ($_vd(.pa.num) > 0) goto loop
  284.   return %.pa.ret
  285. }
  286. _size if ($1 <= 9999) return $1 bytes | if ($calc($1 / 1024) <= 9999) return $int($calc($1 / 1024)) $+ kb | return $int($calc($1 / 1048576)) meg
  287. _size2 if ($calc($1 / 1024) <= 999) return $round($calc($1 / 1024),2) Kb | return $round($calc($1 / 1048576),2) Mb
  288. _ppmask {
  289.   if ($_not($_ismask($1))) {
  290.     if ($1 == $me) set %.pm.mask $me $+ ! $+ %-my.address
  291.     else set %.pm.mask $address($1,5)
  292.     if (%.pm.mask == $null) return $1 $+ !*@*
  293.     set %.pm.mask $replace(%.pm.mask,***,,*,?,,***)
  294.   }
  295.   else set %.pm.mask $_fixmask($1)
  296.   set %.pm.identd $_rchop($pos(%.pm.mask,!),$left(%.pm.mask,$_j($pos(%.pm.mask,@))))
  297.   set %.pm.mask $mask(%.pm.mask,$2)
  298.   set %.pm.dom $gettok(%.pm.mask,2,64)
  299.   if ($left(%.pm.dom,2) == *.) {
  300.     set %.pm.dots $count(%.pm.dom,.)
  301.     if ($right(%.pm.dom,3) == .us) set %.pm.max 4
  302.     elseif ((. isin $right(%.pm.dom,3)) || ($right(%.pm.dom,4) == .mil) || ($right(%.pm.dom,4) == .gov)) set %.pm.max 3
  303.     else set %.pm.max 2
  304.     if (%.pm.dots > %.pm.max) {
  305.       set %.pm.range $calc(%.pm.dots - %.pm.max + 2) $+ - $+ $_i(%.pm.dots)
  306.       set %.pm.mask $gettok(%.pm.mask,1,64) $+ @*. $+ $gettok(%.pm.dom, [ %.pm.range ] ,46)
  307.     }
  308.   }
  309.   set %.pm.len $_j($pos(%.pm.mask,@))
  310.   :loop
  311.   set %.pm.chr $mid(%.pm.mask,%.pm.len,1)
  312.   if (%.pm.chr != !) {
  313.     if ($asc(%.pm.chr) !isnum 33-126) set %.pm.mask $replace(%.pm.mask,%.pm.chr,?)
  314.     dec %.pm.len | goto loop
  315.   }
  316.   if (($2 == 1) || ($2 == 3) || ($2 == 6) || ($2 == 8)) {
  317.     set %.pm.newid $_rchop($pos(%.pm.mask,!),$left(%.pm.mask,$_j($pos(%.pm.mask,@))))
  318.     if (($len(%.pm.identd) <= 2) || (($len(%.pm.identd) == 3) && ($left(%.pm.identd,1) isin ^~+=-))) set %.pm.mask $gettok(%.pm.mask,1,33) $+ ! $+ %.pm.identd $+ @ $+ $gettok(%.pm.mask,2,64)
  319.     elseif ($remove($remove(%.pm.newid,?),*) == $null) set %.pm.mask $gettok(%.pm.mask,1,33) $+ ! $+ %.pm.identd $+ @ $+ $gettok(%.pm.mask,2,64)
  320.     else set %.pm.mask $gettok(%.pm.mask,1,33) $+ ! $+ $replace($replace(%.pm.newid,^,*),=,*) $+ @ $+ $gettok(%.pm.mask,2,64)
  321.   }
  322.   if (*** !isin %.pm.mask) {
  323.     :short | if (** isin %.pm.mask) { set %.pm.mask $replace(%.pm.mask,**,*) | goto short }
  324.   }
  325.   return %.pm.mask
  326. }
  327. _renlogfile {
  328.   set %.rlf.len $len($1)
  329.   set %.rlf $1
  330.   :loop
  331.   set %.rlf.chr $mid(%.rlf,%.rlf.len,1)
  332.   if (%.rlf.chr !isin abcdefghijklmnopqrstuvwxyz_0123456789) set %.rlf $replace(%.rlf,%.rlf.chr,_)
  333.   dec %.rlf.len
  334.   if (%.rlf.len > 0) goto loop
  335.   if ($_ischan($1,1)) set %.rlf $left($1,1) $+ $_rchop(1,%.rlf)
  336.   if (3.1 isin $os) return $left(%.rlf,8) $+ .log
  337.   return %.rlf $+ .log
  338. }
  339. _pwenc {
  340.   unset %.pe
  341.   set %.pe.len $len($1-)
  342.   :loop
  343.   set %.pe %.pe $+ $chr($calc(160 - $asc($mid($1-,%.pe.len,1))))
  344.   if ($_vd(.pe.len) > 0) goto loop
  345.   return %.pe
  346. }
  347. ; -----------------------------------------------------
  348. ; Possibly not belong here in
  349. ; "standard identifiers"
  350. ; -----------------------------------------------------
  351. _antirep if ((%-ar.num !isnum) || (%-ar.num < 1)) set %-ar.num $r(1,9) | elseif (%-ar.num > 9) set %-ar.num 1 | set %.ar.ret $mid(╖.`æÆ┤╕á',%-ar.num,1) | inc %-ar.num | return %.ar.ret
  352. ; Note- Å == 0143
  353. _pat.rand {
  354.   set %.pat.num $_numtok(46,$1)
  355.   set %.pat.pos 1
  356.   set %.pat.len $len($2-)
  357.   set %.pat.text $replace($2-,$chr(32),Å)
  358.   set %.pat Å
  359.   :loop | set %.tok $gettok($1,$r(1,%.pat.num),46) | if (%.tok == $) unset %.tok | set %.pat %.pat $+ %.tok $+ $mid(%.pat.text,%.pat.pos,1) | if ($_vi(.pat.pos) <= %.pat.len) goto loop
  360.   return $replace(%.pat,Å,$chr(32))
  361. }
  362. _pattern {
  363.   set %.pat.num $_numtok(46,$1)
  364.   set %.pat.pos 1 | set %.pat.set 1
  365.   set %.pat.len $len($2-)
  366.   set %.pat.text $replace($2-,$chr(32),Å)
  367.   set %.pat Å
  368.   :loop | set %.pat %.pat $+ $gettok($1,%.pat.set,46) $+ $mid(%.pat.text,%.pat.pos,1) | if ($_vi(.pat.set) > %.pat.num) set %.pat.set 1 | if ($_vi(.pat.pos) <= %.pat.len) goto loop
  369.   return $replace(%.pat,Å,$chr(32))
  370. }
  371. _kickmsg {
  372.   if ($3 == $null) return $_kickwrap($1,$2,$_finalmsg($replace($replace($_getmsg(Kicks,Message),&chan&,$1),&nick&,$2)))
  373.   if ($4 == $null) return $_finalmsg($replace($replace($_getmsg(Kicks,$3),&chan&,$1),&nick&,$2))
  374.   return $_finalmsg($replace($replace($replace($replace($_getmsg(Kicks,$3),&chan&,$1),&nick&,$2),&A&,$4),&B&,$5))
  375. }
  376. _kickwrap return $_finalmsg($replace($replace($replace($_getmsg(Kicks,Wrapper),&msg&,$3-),&chan&,$1),&nick&,$2))
  377. _tkickmsg return $_tkickwrap($1,$2,$3,$_finalmsg($replace($replace($_getmsg(Kicks,TempMessage),&chan&,$1),&nick&,$2)))
  378. _tkickwrap return $_finalmsg($replace($replace($replace($replace($_getmsg(Kicks,TempWrapper),&msg&,$4-),&chan&,$1),&nick&,$2),&dur&,$replace($replace($replace($duration($3),secs,sec),mins,min),hrs,hr)))
  379. _blackmsg {
  380.   set %.bm.ret $replace($replace($replace($_getmsg($1,$2),&chan&,$_f2s($3)),&nick&,$4),&addr&,$5)
  381.   if (&reason& isin %.bm.ret) set %.bm.ret $replace(%.bm.ret,&reason&,$6-)
  382.   else set %.bm.ret %.bm.ret $6-
  383.   return $_finalmsg(%.bm.ret)
  384. }
  385. _opmsg {
  386.   set %.wo.ret $replace($replace($replace($replace($replace($_getmsg(Notice,WallOp),&chan&,$1),&ops&,$opnick($1,0)),&vocs&,$vnick($1,0)),&users&,$nick($1,0)),&ovs&,$calc($opnick($1,0) + $vnick($1,0)))
  387.   if (&msg& isin %.wo.ret) set %.wo.ret $replace(%.wo.ret,&msg&,$_naction($2-))
  388.   else set %.wo.ret %.wo.ret $_naction($2-)
  389.   return $_finalmsg(%.wo.ret)
  390. }
  391. _vocmsg {
  392.   set %.wo.ret $replace($replace($replace($replace($replace($_getmsg(Notice,WallVoc),&chan&,$1),&ops&,$opnick($1,0)),&vocs&,$vnick($1,0)),&users&,$nick($1,0)),&ovs&,$calc($opnick($1,0) + $vnick($1,0)))
  393.   if (&msg& isin %.wo.ret) set %.wo.ret $replace(%.wo.ret,&msg&,$_naction($2-))
  394.   else set %.wo.ret %.wo.ret $_naction($2-)
  395.   return $_finalmsg(%.wo.ret)
  396. }
  397. _massmsg {
  398.   set %.wo.ret $replace($replace($replace($_getmsg(Notice,$1),&chan&,$2),$3,$4),&users&,$nick($2,0))
  399.   if (&msg& isin %.wo.ret) set %.wo.ret $replace(%.wo.ret,&msg&,$_naction($5-))
  400.   else set %.wo.ret %.wo.ret $_naction($5-)
  401.   return $_finalmsg(%.wo.ret)
  402. }
  403. _privn {
  404.   set %.wo.ret $replace($_getmsg(Notice,$1),$2,$3)
  405.   if (&msg& isin %.wo.ret) set %.wo.ret $replace(%.wo.ret,&msg&,$_naction($4-))
  406.   else set %.wo.ret %.wo.ret $_naction($4-)
  407.   return $_finalmsg(%.wo.ret)
  408. }
  409. _naction if ($1 == /me) return * $me $2- | else return $1-
  410. ; $_nickcomp(partial,#chan)
  411. _nickcomp {
  412.   if (" isin $1) return $remove($1,")
  413.   if (($2 == $null) || ($chr(44) isin $1) || (* isin $1) || (! isin $1) || (@ isin $1)) return
  414.   if ($1 ison $2) return $ial($1!*,1).nick
  415.   if (%+nick.complete.skipifmany) if ($ialchan($1*!*@*,$2,0) > 1) return
  416.   if ($ialchan($1*!*@*,$2,1).nick != $null) return $ialchan($1*!*@*,$2,1).nick
  417.   set %.nc.num $nick($2,0)
  418.   :loop2
  419.   if ($1* iswm $remove($remove($remove($remove($remove($remove($remove($remove($remove($remove($nick($2,%.nc.num),-),_),[),]),$chr(125)),$chr(123)),\),|),`),^)) return $nick($2,%.nc.num)
  420.   if ($_vd(.nc.num) > 0) goto loop2
  421.   return
  422. }
  423. ; $_nickglob(partial) finds nickcomplete in any chan (starting in current if any) or returns partial if none found
  424. ; Returns partial if quoted
  425. _nickglob {
  426.   if ($1 == $null) return
  427.   if (" isin $1) return $remove($1,")
  428.   if ($_not(%+nick.complete.cmd)) return $1
  429.   if (($chr(44) isin $1) || (* isin $1) || (! isin $1) || (@ isin $1)) return $1
  430.   if ($ial($1!*,0) > 0) return $ial($1!*,1).nick
  431.   if ($1 isnotify) return $1
  432.   if (%+nick.complete.skipifmany) if ($ial($1*!*@*,0) > 1) return $1
  433.   if ($chan($active) == $active) { set %.ng.nick $_nickcomp($1,$active) | if (%.ng.nick != $null) return %.ng.nick }
  434.   set %.ng.num $chan(0)
  435.   :loop
  436.   if ($chan(%.ng.num) != $active) {
  437.     set %.ng.nick $_nickcomp($1,$chan(%.ng.num))
  438.     if (%.ng.nick != $null) return %.ng.nick
  439.   }
  440.   if ($_vd(.ng.num) > 0) goto loop
  441.   set %.nm $notify(0)
  442.   :golbez
  443.   if ($1* iswm $notify(%.nm)) if ($notify(%.nm).ison) return $notify(%.nm)
  444.   if ($_vd(.nm) > 0) goto golbez
  445.   return $1
  446. }
  447. ; Returns nick completion for a series of nicks
  448. ; $_nickseries(token,series)
  449. _nickseries {
  450.   if ($2 == $null) return
  451.   if ($_not(%+nick.complete.cmd)) return $remove($2-,")
  452.   set %.ns.max $_numtok($1,$2-)
  453.   set %.ns.num 1
  454.   unset %.ns.ret
  455.   :loop
  456.   set %.ns.ret $addtok(%.ns.ret,$_nickglob($gettok($2-,%.ns.num,$1)),$1)
  457.   if ($_vi(.ns.num) <= %.ns.max) goto loop
  458.   return %.ns.ret
  459. }
  460. ; Returns nick completion for a series of nicks for one chan
  461. ; $_nickcseries(token,#chan,series)
  462. _nickcseries {
  463.   if ($3 == $null) return
  464.   if ($_not(%+nick.complete.cmd)) return $remove($3-,")
  465.   set %.ns.ret $3-
  466.   set %.ns.max $_numtok($1,$3-)
  467.   set %.ns.num 1
  468.   :loop
  469.   set %.ns.get $gettok(%.ns.ret,%.ns.num,$1)
  470.   set %.ns.got $_nickcomp(%.ns.get,$2)
  471.   if (%.ns.got != $null) set %.ns.ret $puttok(%.ns.ret,%.ns.got,%.ns.num,$1)
  472.   if ($_vi(.ns.num) <= %.ns.max) goto loop
  473.   return %.ns.ret
  474. }
  475. ; strips COLORS ONLY
  476. _stripc {
  477.   if ( !isin $1-) return $1-
  478.   set %.sc.todo ! $+ $_s2f($1-)
  479.   set %.sc.tok $_numtok(3,%.sc.todo)
  480.   set %.sc.num 1
  481.   unset %.sc.ret
  482.   :loop
  483.   set %.sc.chk $gettok(%.sc.todo,%.sc.num,3)
  484.   if ($left(%.sc.chk,2) isnum) set %.sc.chk $_rchop(2,%.sc.chk)
  485.   elseif ($left(%.sc.chk,1) isnum) set %.sc.chk $_rchop(1,%.sc.chk)
  486.   else goto nost
  487.   if ($left(%.sc.chk,1) == ,) {
  488.     set %.sc.chk2 $_rchop(1,%.sc.chk)
  489.     if ($left(%.sc.chk2,2) isnum) set %.sc.chk $_rchop(2,%.sc.chk2)
  490.     elseif ($left(%.sc.chk2,1) isnum) set %.sc.chk $_rchop(1,%.sc.chk2)
  491.   }
  492.   :nost
  493.   set %.sc.ret %.sc.ret $+ %.sc.chk
  494.   if ($_vi(.sc.num) <= %.sc.tok) goto loop
  495.   return $_f2s($_rchop(1,%.sc.ret))
  496. }
  497. ; strips according to %+strip.out.colors and %+strip.out.codes
  498. _stripout {
  499.   if ($1 == $null) return
  500.   if (%+strip.out.codes) return $strip($1-)
  501.   if (%+strip.out.colors) return $_stripc($1-)
  502.   return $1-
  503. }
  504. _center {
  505.   if ($3 == $null) return $int($calc(( [ $window(-3).w ] - $1) / 2)) $int($calc(( [ $window(-3).h ] - $2) / 2))
  506.   else return $int($calc(( [ $window(-1).w ] - $1) / 2)) $int($calc(( [ $window(-1).h ] - $2) / 2))
  507. }
  508. ; Returns position and size for a window with padding $1 top $2 bottom $3 left $4 right. In pixels, #% for percents, nondesktop
  509. _winpos {
  510.   if (% isin $1) set %.p.1 $int($calc( [ $window(-3).h ] * $remove($1,%) / 100)) | else set %.p.1 $1
  511.   if (% isin $2) set %.p.2 $int($calc( [ $window(-3).h ] * $remove($2,%) / 100)) | else set %.p.2 $2
  512.   if (% isin $3) set %.p.3 $int($calc( [ $window(-3).w ]  * $remove($3,%) / 100)) | else set %.p.3 $3
  513.   if (% isin $4) set %.p.4 $int($calc( [ $window(-3).w ]  * $remove($4,%) / 100)) | else set %.p.4 $4
  514.   return %.p.3 %.p.1 $calc( [ $window(-3).w ] - %.p.3 - %.p.4) $calc( [ $window(-3).h ] - %.p.1 - %.p.2)
  515. }
  516. ; $_findwm(*a*,this is a bad routine) == bad; not find returns wildcard string minus */?
  517. _findwm {
  518.   set %.wm.num $_numtok(32,$2-)
  519.   :loop
  520.   set %.wm.tok $gettok($2-,%.wm.num,32)
  521.   if ($1 iswm %.wm.tok) return %.wm.tok
  522.   if ($_vd(.wm.num) > 0) goto loop
  523.   return $remove($remove($1,*),?)
  524. }
  525. _fixncol if ($1 == $null) return  | return $1
  526. ; adds $mircdir if no drive, for use with $read, also calls $_wrapfile
  527. _adddir if (: !isin $1) { if ($left($1,1) == \) return $_wrapfile( [ [ $left($mircdir,2) ] $+ [ $1- ] ] ) | return $_wrapfile($mircdir [ $+ [ $1- ] ] ) } | return $_wrapfile($1-)
  528. ; Wraps in quotes if spaces
  529. _wrapfile {
  530.   if ($2 == $null) return $remove($1,")
  531.   if ($shortfn($remove($1-,"))) return $ifmatch
  532.   %.wftok = $gettok($remove($1-,"),0,92)
  533.   %.wfran = 1- $+ $calc(%.wftok -1)
  534.   return $shortfn($gettok($remove($1-,"),%.wfran,92)) $+ \ $+ $gettok($remove($1-,"),%.wftok,92)
  535. }
  536. ; $remove for a single char from a single word, case sensitive
  537. _caserem {
  538.   set %.clen 1
  539.   unset %.cret
  540.   :loop
  541.   if ($mid($1,%.clen,1) !== $2) set %.cret %.cret $+ $mid($1,%.clen,1)
  542.   if (%.clen < $len($1)) { inc %.clen | goto loop }
  543.   return %.cret
  544. }
  545. ; Scales tabs
  546. _tabscale {
  547.   set %.tret $_s2c($1-)
  548.   set %.tokn $_numtok(44,%.tret)
  549.   :loop
  550.   set %.tret $puttok(%.tret,$int($calc($gettok(%.tret,%.tokn,44) * %font.fixtab / 18)),%.tokn,44)
  551.   if ($_vd(.tokn) > 0) goto loop
  552.   return -t $+ %.tret
  553. }
  554. ;
  555. _BLsave {
  556.   if ($exists($1-)) .remove $1-
  557.   set %.sav.max $line(@Banlist,0)
  558.   set %.sav.num 5
  559.   :loop
  560.   if (- !isin $gettok($line(@Banlist,%.sav.num),1,9)) write $_wrapfile($1-) $gettok($line(@Banlist,%.sav.num),2,9)
  561.   if ($_vi(.sav.num) <= %.sav.max) goto loop
  562.   _recfile2 $1-
  563.   titlebar @Banlist $window(@Banlist).titlebar - Saved to $1-
  564. }
  565. _BLimport {
  566.   set %.sav.num 1
  567.   :loop
  568.   set %.sav.ban $read -l [ $+ [ %.sav.num ] ] $_wrapfile($1-)
  569.   if (%.sav.ban != $null) {
  570.     if ($_ismask(%.sav.ban)) _BLmodban + $gettok(%.sav.ban,1,32) -a
  571.     inc %.sav.num
  572.     goto loop
  573.   }
  574. }
  575. _chksends {
  576.   if ($send(0) == %lastnum.send) return
  577.   elseif ($send(0) < %lastnum.send) { set %lastnum.send $send(0) | return }
  578.   else {
  579.     :loop
  580.     inc %lastnum.send
  581.     set %.dt.file $send(%lastnum.send).path $+ $send(%lastnum.send).file
  582.     _recfile Sends %.dt.file | _recfile Files %.dt.file
  583.     if (%+dccincomp.enable) _recinc s $send(%lastnum.send) %.dt.file
  584.     if ($send(0) > %lastnum.send) goto loop
  585.   }
  586. }
  587. _nomrej set %-mirc.rejoins $remtok(%-mirc.rejoins,$2,32)
  588. _dolonemode {
  589.   if (%alonetopic. [ $+ [ $1 ] ] != $null) .raw topic $1 : $+ %alonetopic. [ $+ [ $1 ] ]
  590.   elseif (%onoptopic. [ $+ [ $1 ] ] != $null) .raw topic $1 : $+ %onoptopic. [ $+ [ $1 ] ]
  591.   elseif (%stricttopic. [ $+ [ $1 ] ] != $null) .raw topic $1 : $+ %stricttopic. [ $+ [ $1 ] ]
  592.   set %.mode1 $_setting(strictmode,$1)
  593.   set %.mode2 $_setting(onopmode,$1)
  594.   set %.mode3 $_setting(alonemode,$1)
  595.   set %.mode $gettok(%.mode1,1,32) $+ $gettok(%.mode2,1,32) $+ $gettok(%.mode3,1,32) $gettok(%.mode1,2-,32) $gettok(%.mode2,2-,32) $gettok(%.mode3,2-,32)
  596.   if ($remove($remove(%.mode,+),-) != $null) {
  597.     .raw mode $1 %.mode
  598.     if (k isin %.mode) .timer923 1 8 _chkkey $1
  599.   }
  600. }
  601.